import React from 'react';
import './index.less';
import { useHistory } from 'react-router-dom';

interface TitleProps {
  title: string;
  left?: boolean;
  right?: any;
}
function Title(props: TitleProps) {
  const back = '<';
  const history = useHistory();
  console.log('title props:', props);
  return (
    <div className='header'>
      {props.left === true ? (
        <span className='title-left' onClick={() => history.go(-1)}>
          {back}
        </span>
      ) : (
        ''
      )}
      <div className='title-center'>
        {props.title}
      </div>
      <div className='title-right'>{props.right}</div>
    </div>
  );
}
export default Title;
